import { ExtractPropTypes } from "vue"
import { array as isArray} from '../../utils'

/**
 * 动画有效值
 */
const AnimationModes = ['fade', 'slide-top', 'slide-bottom', 'slide-right', 'slide-left', 'zoom-in', 'zoom-out'] as const
export type AnimationMode = typeof AnimationModes[number]

/**
 * 动画参数类型
 */
export type AnimationOptionsTimingFunction = 'linear' | 'ease' | 'ease-in' | 'ease-in-out' | 'ease-out' | 'step-start' | 'step-end'
export type AnimationOptions = {
  /** 持续时间 */
  duration?: number,
  /** 动画效果 */
  timingFunction?: AnimationOptionsTimingFunction,
  /** 动画延迟时间 */
  delay?: number,
  /** transformOrigin */
  transformOrigin?: string
}

/**
 * props参数
 */
export const transitionProps = {
  /** 显示动画 */
  show: {
    type: Boolean,
    default: false
  },
  /** 动画类型 */
  mode: {
    type: [Array, String],
    default: () => {
      return 'fade'
    }
  },
  /** 持续时间 */
  duration: {
    type: [String, Number],
    default: 300
  },
  /** 自定义样式 */
  customStyle: {
    type: Object,
    default: () => {
      return {}
    }
  },
  /** 自定义类 */
  customClass: {
    type: String,
    default: ''
  }
}
export type TransitionProps = ExtractPropTypes<typeof transitionProps>

export const transitionEmits = {
  /** 点击事件 */
  click: () => true,
  /** 动画显示事件 */
  enter: (status: boolean) => typeof status === 'boolean',
  /** 动画关闭事件 */
  leave: (status: boolean) => typeof status === 'boolean'
}
export type TransitionEmits = typeof transitionEmits
